package cn.yangliu.utils;



import cn.yangliu.entity.PayEntity;
import cn.yangliu.entity.PayOrderInfo;
import cn.yangliu.enums.PayStatusEnum;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by mechrevo
 * on 2017/5/23 0023.
 */
public class OrderUtils {

    public static synchronized String createOrderNo() {
        String order = DateUtils.date2String(new Date(), "yyyyMMddHHmmss");
        order += StringUtils.getRandomNum(10);
        return order;
    }

    public static PayOrderInfo createOrderInfo(PayEntity payInfo, String payType, String orderNo) {
        PayOrderInfo orderInfo = new PayOrderInfo();

         String status = PayStatusEnum.INIT.getStatus();

         BigDecimal price = payInfo.getPrice();

         BigDecimal amount = payInfo.getAmount();

         Integer count = payInfo.getCount();

         String desp = payInfo.getDesp();

         String goods = payInfo.getGoods();

         orderInfo.setAmount(amount);
         orderInfo.setCreateTime(new Date());

         orderInfo.setCount(count);

         orderInfo.setDesp(desp);
         orderInfo.setGoods(goods);
         orderInfo.setPrice(price);
         orderInfo.setStatus(status);
         orderInfo.setPayType(payType);
         orderInfo.setOrderNo(orderNo);
        return orderInfo;
    }

}
